#include "..\examples\src\shared\gltools.h"

void RenderScene()
{
	static float r = 0.0f;
	static float angle = 0.0f;
	static float z = -70.0f;

	glBegin(GL_POINTS);
		glVertex3d(r * cos(angle), r * sin(angle), z); 
	glEnd();

	r += 0.1f;
	angle += 0.1f;

	glFlush();
}

void Timer(int value)
{
	glutTimerFunc(50, Timer, 0);
	glutPostRedisplay();
}

void ChangeSize(GLsizei w, GLsizei h)
{
	GLfloat nRange = 100.0f;
	if (h == 0)
		h = 1;

	GLfloat aspectRatio = static_cast<GLfloat>(w) / static_cast<GLfloat>(h);

	glViewport(0, 0, w, h);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	if (w <= h)
	{
		glOrtho(-nRange, nRange, -nRange / aspectRatio, nRange / aspectRatio, -nRange, nRange);
	}
	else
	{
		glOrtho(-nRange * aspectRatio, nRange * aspectRatio, -nRange, nRange, -nRange, nRange);
	}

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

}

void SetupRC()
{
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glColor3f(0.0f, 1.0f, 0.0f);
}

int main(int argc, char * argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutCreateWindow("single");
	glutDisplayFunc(RenderScene);
	glutReshapeFunc(ChangeSize);
	glutTimerFunc(50, Timer, 0);

	SetupRC();
	glutMainLoop();

	return 0;
}